package com.kzj.laimeimei.recyclerCard.cardView;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.TextView;

import com.kzj.laimeimei.R;
import com.kzj.laimeimei.global.App;
import com.kzj.laimeimei.recyclerCard.basic.CardItemView;
import com.kzj.laimeimei.recyclerCard.card.other.CouponsCard;
import com.kzj.laimeimei.util.ImageUtil;

/**
 * Created by xyg on 2015/10/26.
 */
public class CouponsCardView extends CardItemView<CouponsCard> {

    private Context context;
    private ImageView imageView_bg;
    private TextView textView_name;
    private TextView textView_time;
    private TextView textView_value;
    private TextView textView_fuhao;

    public CouponsCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public CouponsCardView(Context context) {
        super(context);
        this.context = context;
    }

    public CouponsCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(final CouponsCard card) {
        super.build(card);
        imageView_bg = (ImageView) findViewById(R.id.imageView_bg);
        textView_name = (TextView) findViewById(R.id.textView_name);
        textView_time = (TextView) findViewById(R.id.textView_time);
        textView_value = (TextView) findViewById(R.id.textView_value);
        textView_fuhao = (TextView) findViewById(R.id.textView_fuhao);
        textView_name.setText(card.getCouponBean().getCoupon_name());
        textView_time.setText("有效期至"+card.getCouponBean().getEnd_time());
        textView_value.setText(card.getCouponBean().getCoupon_value());
        if (card.getCouponBean().getIs_use()) {
            App.imageLoader.displayImage("drawable://" + R.drawable.coupon_can_use, imageView_bg, ImageUtil.OptionsNormal());
            textView_time.setTextColor(getResources().getColor(R.color.color_1a1a1a_black));
            textView_name.setTextColor(getResources().getColor(R.color.color_1a1a1a_black));

            textView_fuhao.setTextColor(getResources().getColor(R.color.color_f875a3_red));
            textView_value.setTextColor(getResources().getColor(R.color.color_f875a3_red));
        } else {
            App.imageLoader.displayImage("drawable://" + R.drawable.coupon_cant_use, imageView_bg, ImageUtil.OptionsNormal());
            textView_time.setTextColor(getResources().getColor(R.color.color_d1d1d1_gray));
            textView_name.setTextColor(getResources().getColor(R.color.color_d1d1d1_gray));

            textView_fuhao.setTextColor(getResources().getColor(R.color.color_fdd5e3_red));
            textView_value.setTextColor(getResources().getColor(R.color.color_fdd5e3_red));
        }
    }
}
